part of internal;

class Node<Item> {
   Item _item;
   Node<Item> _prev;
   Node<Item> _next;

   // generator
   Node (Item neww) {
      if (dev) if (neww == null) argErr(neww);
      _item = neww;
      if (dev) if (!valid) staErr(this);
   }

   // mutators
   void set item (Item neww) {
      if (dev) if (neww == null) argErr(neww);
      _item = neww;
      if (dev) if (!valid) staErr(this);
   }
   void set prev (Node<Item> neww) {
      if (dev) if (neww == this) argErr(neww);
      _prev = neww;
      if (dev) if (!valid) staErr(this);
   }
   void set next (Node<Item> neww) {
      if (dev) if (neww == this) argErr(neww);
      _next = neww;
      if (dev) if (!valid) staErr(this);
   }

   // observers
   Item get item => _item;
   Node<Item> get prev => _prev;
   Node<Item> get next => _next;

   // invariants
   bool get valid {
      if (_item == null) return false;
      if (_prev == this) return false;
      if (_next == this) return false;
      return true;
   }

   // printing
   String toString () => 'item -> $_item';
}
